<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>学生打卡统计报告</title>
    <style>
        body { 
            font-family: Arial, sans-serif; 
            margin: 20px; 
            background-color: #f5f5f5;
        }
        .header { 
            text-align: center; 
            margin-bottom: 20px; 
            color: #333;
        }
        .class-section { 
            margin-bottom: 30px; 
            background-color: white;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .class-title { 
            background: linear-gradient(135deg, #4CAF50, #45a049);
            color: white; 
            padding: 15px; 
            margin-bottom: 15px; 
            font-weight: bold;
            border-radius: 5px;
            text-align: center;
        }
        table { 
            width: 100%; 
            border-collapse: collapse; 
            margin-bottom: 20px; 
            background-color: white;
        }
        th, td { 
            border: 1px solid #ddd; 
            padding: 12px; 
            text-align: center; 
        }
        th { 
            background: linear-gradient(135deg, #f8f9fa, #e9ecef);
            font-weight: bold;
            color: #495057;
        }
        .status-submitted { 
            color: #28a745; 
            font-weight: bold; 
            background-color: #d4edda;
            padding: 4px 8px;
            border-radius: 3px;
        }
        .status-not-submitted { 
            color: #dc3545; 
            font-weight: bold; 
            background-color: #f8d7da;
            padding: 4px 8px;
            border-radius: 3px;
        }
        .summary { 
            background: linear-gradient(135deg, #e8f5e8, #d4edda);
            padding: 20px; 
            margin-top: 20px; 
            border-radius: 8px;
            border-left: 5px solid #28a745;
        }
        .summary h3 {
            color: #155724;
            margin-top: 0;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>学生打卡统计报告</h1>
        <p th:text="'统计时间：' + ${startDate}"></p>
        <p th:text="'负责教师：' + ${teacherName}"></p>
    </div>

    <!-- 遍历每个班级的数据 -->
    <div th:each="classData : ${classDataList}" class="class-section">
        <h2 class="class-title" th:text="${classData.className} + ' 学生打卡信息'"></h2>
        
        <table>
            <thead>
                <tr>
                    <th>序号</th>
                    <th>姓名</th>
                    <th>英文名</th>
                    <th th:each="dateColumn : ${classData.dateColumns}" th:text="${dateColumn}"></th>
                    <th>积分</th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="student, iterStat : ${classData.studentData}">
                    <td th:text="${iterStat.count}"></td>
                    <td th:text="${student.studentName}"></td>
                    <td th:text="${student.englishName != null ? student.englishName : ''}"></td>
                    <td th:each="dateColumn : ${classData.dateColumns}">
                        <span th:text="${student.dailyStatus}"></span>
                    </td>
                    <td th:text="${student.totalScore != null ? student.totalScore : 0}"></td>
                </tr>
            </tbody>
        </table>

        <!-- 班级统计摘要 -->
        <div class="summary">
            <strong>班级统计：</strong>
            总学生数：<span th:text="${classData.totalStudents}"></span> |
            总提交次数：<span th:text="${classData.totalSubmissions}"></span> |
            已提交次数：<span th:text="${classData.submittedCount}"></span> |
            出勤率：<span th:text="${classData.attendanceRate} + '%'"></span>
        </div>
    </div>

    <div style="text-align: center; margin-top: 30px; color: #666; font-size: 12px;">
        <p>发送时间：<span th:text="${#dates.format(#dates.createNow(), 'yyyy-MM-dd HH:mm:ss')}"></span></p>
    </div>
</body>
</html>